package com.loong.system.business;

import com.loong.common.mybatis.business.AbstractBusiness;
import com.loong.system.common.backend.param.SystemFeedbackTypeParam;
import com.loong.system.common.backend.param.SystemFeedbackTypeQueryParam;
import com.loong.system.model.SystemFeedbackType;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.entity.Condition;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * @author LiuQun
 * @date 2020-09-28 9:12
 */
@Repository
public class SystemFeedbackTypeBusiness extends AbstractBusiness<SystemFeedbackType> {
    /**
     *根据参数查询用户反馈类型
     * @param param 查询参数
     * @return 反馈类型
     */
    public List<SystemFeedbackType> findFeedbackTypeByParam(SystemFeedbackTypeQueryParam param) {
        Condition condition = new Condition(SystemFeedbackType.class);
        Example.Criteria criteria = condition.createCriteria();
        if (ObjectUtils.isNotEmpty(param.getName())) {
            criteria.andLike("name", "%" + param.getName() + "%");
        }
        if (ObjectUtils.isNotEmpty(param.getUserType())) {
            criteria.andEqualTo("userType", param.getUserType());
        }
        if (ObjectUtils.isNotEmpty(param.getStartTime())){
            criteria.andGreaterThanOrEqualTo("createTime",param.getStartTime());
        }
        if (ObjectUtils.isNotEmpty(param.getEndTime())){
            criteria.andLessThanOrEqualTo("createTime",param.getEndTime());
        }
        return findByCondition(condition);
    }
}
